package Gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.MalformedURLException;
import java.net.URL;

import GameFiles.GameManager;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class YardSalePanel extends Frame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4217879108768264362L;
	private static YardSalePanel ref;
	private Dimension size;
	private Image img;
	
	private YardSalePanel() {
		setName("Yard Sale!");
		Panel p = new Panel();
		p.setLayout(new FlowLayout(FlowLayout.RIGHT, 10, 5));
		this.add(p, "South");
		try
		{
			img = new ImageIcon(new URL("http://www.stevenbankhead.com/GSP_Project/Images/yardsaleImage.jpg")).getImage();
		} catch (MalformedURLException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		size = new Dimension(img.getWidth(null), img.getHeight(null));
		setSize(size);
		setMinimumSize(size);

		JButton ok = new JButton("OK");
		ok.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});

		add(ok, BorderLayout.SOUTH);
		this.pack();
		setVisible(true);
		generateDealCard();
	}
	private void generateDealCard(){
		GameManager.getInstance().RollDice();
		int a_dealCard=(GameManager.getInstance().getDice1())*100;
		
	}

	public void paintComponent(Graphics g) {
		//int imgX = getSize().width / 2 - img.getWidth(this);
		//int imgY = getSize().height / 2 - img.getHeight(this);
		//g.drawImage(img, imgX, imgY, this);
	}

	public boolean Enter() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean Execute() {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean Exit() {
		// TODO Auto-generated method stub
		return false;
	}

	public static YardSalePanel getInstance() {
		if (ref == null)
			// it's ok, we can call this constructor
			ref = new YardSalePanel();
		return ref;
	}
}
